package com.lagou.task.servlet;

import com.lagou.task.model.Student;
import com.lagou.task.service.StudentService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "ShowAllServlet", urlPatterns = "/showAll")
public class ShowAllServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        StudentService studentService = new StudentService();
        List<Student> students = studentService.studentSelectAll();
        request.getSession().setAttribute("stds",students);
        request.getRequestDispatcher("/stdShowAll.jsp").forward(request,response);
    }
}
